package ae.pcfc.cldos.online.web.controller.base;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;

import ae.pcfc.cldos.online.common.delegate.SystemValuesDelegate;


/**
 * A Child of BASE Controller, and super class for all the controllers
 * all controller must extend this class
 * @author ammar
 *
 */
public abstract class BasePageController extends BaseController {
	
	
	protected SystemValuesDelegate getSystemValuesDelegate() {
		return systemValuesDelegate;		
	}	
	
	@Autowired
	@Qualifier("systemValuesDelegate")
	protected SystemValuesDelegate systemValuesDelegate;
	
	@ModelAttribute
	public void populateCommonData(ModelMap model){
		if(securityService.isAuthenticated()){
			if(securityService.isCompanyAdmin() || securityService.isCompanyEmployee()){
				model.put("newTasksCount", adminTaskDelegate.getNewTasksCount(getUserVO()));
				model.put("newNotificationsCount", adminTaskDelegate.getNewNotificationsCount(getUserVO()));
			}
		}
	}
}
